
package todolist.logic.parser;

import todolist.entity.DateTimeEntity;
import todolist.entity.TaskEntity;
import todolist.personalization.ErrorMessages;

/**
 * Parsed DT Description, along with error message if any.
 * Also validates date sequence.
 * @author Ivan
 */
public class DateTimeParseResult {

	private DateTimeEntity _entStartDT;
	private DateTimeEntity _entEndDT;
	private String _strError;
	
	/**
	 * Both DT, as well as Error message, initialized to null.
	 */
	public DateTimeParseResult() {
		_entStartDT = null;
		_entEndDT = null;
		_strError = null;
	}
	
	// getters
	
	public DateTimeEntity getStartDT() {
		return _entStartDT;
	}
	
	public DateTimeEntity getEndDT() {
		return _entEndDT;
	}

	/**
	 * Error message if present, or else null.
	 */
	public String getError() {
		return _strError;
	}
	
	// setters
	
	public void setStartDT(DateTimeEntity pentStartDT) {
		if (!TaskEntity.validateDateSequence(pentStartDT, _entEndDT)) {
			_strError = ErrorMessages.ERR_DATE_SEQUENCE;
			return;
		}
		_entStartDT = pentStartDT;
	}
	
	public void setEndDT(DateTimeEntity pentEndDT) {
		if (!TaskEntity.validateDateSequence(_entStartDT, pentEndDT)) {
			_strError = ErrorMessages.ERR_DATE_SEQUENCE;
			return;
		}
		_entEndDT = pentEndDT;
	}
	
	/**
	 * Error message if present, or else null.
	 */
	public void setError(String pstrError) {
		_strError = pstrError;
	}
	
}
